﻿/////////////////////////////////////////////////////////////////////
//
//	Map_FVG C# Class Library.
//
//	MainWindow
//	scheda principale
//
//	autore: Gustavo Mainardi 
//	versione: 1.0
//	data: 01/12/2015
//
//
//	Cronologia delle versioni:
//
//	Versione 1.0 01/12/2015
//		versione originale
//
//////////////////////////////////////////////////////////////////////////

using System;
using System.Windows.Forms;

namespace Map_Fvg
{
    public partial class MainWindow : Form
    {
        public static Form formViewQQ;
        
        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_Load(object sender, EventArgs e)
        {
            FormIniz newMDIChild = new FormIniz();
            newMDIChild.MdiParent = this;
            newMDIChild.Show();
            newMDIChild.WindowState = FormWindowState.Maximized;
        }

        //
        //      File
        //
        private void salvataggioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ViewQ.noFilesSelected != 1) return;

            if (formViewQQ != null)
            {
                Save savef = new Save();

                savef.SaveFile(this);

            }
        }

        private void stampaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            {

                Print dlg = new Print();
                dlg.Show();
            }
        }

        private void unioneMappeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ViewQ.noFilesSelected != 1) return;
            UnioneDialog dlg = new UnioneDialog();

            DialogResult dr = dlg.ShowDialog();
            if (dr == DialogResult.OK)
            {
                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }
        }

        //
        //      Temi
        //

        private void lineeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LineeDialog dlg = new LineeDialog();

            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }
        }


        private void areeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AreaDialog dlg = new AreaDialog();

            if (DialogResult.OK == dlg.ShowDialog())
            {

                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();

                }
            }
        }

        private void puntiToolStripMenuItem_Click(object sender, EventArgs e)
        {

            PointDialog dlg = new PointDialog();

            if (DialogResult.OK == dlg.ShowDialog())
            {

                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }

        }

        private void testoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TestoDialog dlg = new TestoDialog();

            if (DialogResult.OK == dlg.ShowDialog())
            {

                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }
        }

        private void modificaCodiciToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Codici2 dlg = new Codici2();
        }

        //
        //       Scala
        //
        private void toolStripMenuItem8_Click(object sender, EventArgs e)
        {
            //  scala  1:2000
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 2000.0F;

            if (formViewQQ != null)
            {
                formViewQQ.Refresh();
            }
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            //  scala  1:3000
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 3000.0F;

            if (formViewQQ != null)
            {
                formViewQQ.Refresh();
            }
        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            //  scala  1:4000
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 4000.0F;

            if (formViewQQ != null)
            {
                formViewQQ.Refresh();
            }
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            //      scala 1:5000
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 5000.0F;

            if (formViewQQ != null)
            {
                this.Refresh();

            }
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            //  scala  1:7500
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 7500.0F;

            if (formViewQQ != null)
            {
                formViewQQ.Refresh();
            }
        }

        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
            //  scala  1:10000
            ViewQ.scalaXY = (float)ViewQ.scalaIniziale / 10000.0F;

            if (formViewQQ != null)
            {
                formViewQQ.Refresh();
            }
        }

        private void altraScalaToolStripMenuItem_Click(object sender, EventArgs e)
        {

            AltraScala dlg = new AltraScala();

            dlg.ShowDialog();

            if (dlg.DialogResult == DialogResult.OK)
            {
                formViewQQ.Refresh();
            }
        }

        //
        //      Selezione
        //
        private void selezioneToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (ViewQ.tipo_selezione == 0)
            {

                areeToolStripMenuItem1.Checked = false;
                lineeToolStripMenuItem1.Checked = false;
                puntiToolStripMenuItem1.Checked = false;
                testoToolStripMenuItem1.Checked = false;
                ViewQ.inserimento_modo = 0;
            }
        }

        ///         selezione aree

        private void areeToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.area;

            areeToolStripMenuItem1.Checked = true;
        }


        //  selezione linee

        private void tramiteMouseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.linea;

            lineeToolStripMenuItem1.Checked = true;

        }

        private void tramiteIdentificativoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dlgIdentificativo dlg = new dlgIdentificativo();

            DialogResult dr = dlg.ShowDialog();
            if (dr == DialogResult.OK)
            {
                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }
        }

        private void elencoSentieriToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ElencoSentieri.option = 0;

            ElencoSentieri dlg = new ElencoSentieri();

            DialogResult dr = dlg.ShowDialog();
            if (dr == DialogResult.OK)
            {
                if (formViewQQ != null)
                {
                    formViewQQ.Refresh();
                }
            }
        }
        ///         selezione punti

        private void puntiToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.punto;

            puntiToolStripMenuItem1.Checked = true;
        }

        ///         selezione testo

        private void testoToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.testo;

            testoToolStripMenuItem1.Checked = true;
        }

        //
        //      aggiunta elementi
        //

        private void aggiuntaElementiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            testoToolStripMenuItem2.Checked = false;
        }

        private void areaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("non ancora operante");
        }
        ///         inserimento nuove linee

        private void tracciamentoNuovaLineaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ViewQ.option_selected = 5;
            tracciamentoNuovaLineaToolStripMenuItem.Checked = true;
            ampliamentoUltimaLineaToolStripMenuItem.Checked = false;
            importazioneLineaToolStripMenuItem.Checked = false;
            ViewQ.newPnt = 0;
            ViewQ.Select_flag = (int)ViewQ.flagSelez.linea;
            ViewQ.inserimento_modo = 1;
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.linea;
            ViewQ.initial_flag = 1;
        }

        private void ampliamentoUltimaLineaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ViewQ.option_selected = 6;
            ampliamentoUltimaLineaToolStripMenuItem.Checked = true;
            tracciamentoNuovaLineaToolStripMenuItem.Checked = false;
            importazioneLineaToolStripMenuItem.Checked = false;
            ViewQ.Select_flag = 1;
            ViewQ.inserimento_modo = 2;
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.linea;
            ViewQ.initial_flag = 1;
        
        }

        private void importazioneLineaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ampliamentoUltimaLineaToolStripMenuItem.Checked = false;
            tracciamentoNuovaLineaToolStripMenuItem.Checked = false;
            importazioneLineaToolStripMenuItem.Checked = true;
            if (formViewQQ != null)
            {
                ViewQ.importa_linee();
                formViewQQ.Refresh();
            }
        }

        private void puntoToolStripMenuItem_Click(object sender, EventArgs e)
        {

            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.punto;
            ViewQ.Select_flag = 0;
            ViewQ.inserimento_modo = 1;

            puntoToolStripMenuItem.Checked = true;

        }

        ///         aggiunta testo

        private void testoToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            ViewQ.tipo_selezione = (int)ViewQ.flagSelez.testo;
            ViewQ.Select_flag = 0;
            ViewQ.inserimento_modo = 1;
            testoToolStripMenuItem2.Checked = true;
        }

        //
        //  GPS
        //
        private void standardVerificaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GPS.option = 1;

            GPS dlg = new GPS();

            if (GPS.option == 0) return;
            DialogResult dr = dlg.ShowDialog();

        }

        private void standardInserimentoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GPS.option = 2;

            GPS dlg = new GPS();

            if (GPS.option == 0) return;

            DialogResult dr = dlg.ShowDialog();

        }
 
        private void qstarzVerificaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GPS.option = 3;

            GPS dlg = new GPS();

            if (GPS.option == 0) return;

            DialogResult dr = dlg.ShowDialog();
        }

        private void qstarzInserimentoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GPS.option = 4;

            GPS dlg = new GPS();

            if (GPS.option == 0) return;

            DialogResult dr = dlg.ShowDialog();

        }

        //
        //      Info
        //

        private void informazioniToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InfoBox dlg = new InfoBox();
            dlg.load();
        }

        private void statisticheToolStripMenuItem_Click(object sender, EventArgs e)
        {
            stat dlg = new stat();

            dlg.load();
        }

        private void MainWindow_SizeChanged(object sender, EventArgs e)
        {
             if (formViewQQ != null)
             {
                  formViewQQ.Refresh();
             }

        }

 

    }
}
